<?php
namespace backend\controllers;

use Yii;
use yii\base\Controller;
use yii\data\Pagination;
use backend\models\TaoZhuang;
use backend\models\TaoZhuangSearch;
use yii\data\Sort;

class TzController extends Controller {
    public $layout = "main";
    function actionIndex() {
//         $query = TaoZhuang::find();
        
//         $sort = new Sort([
//             "attributes" => [
//                 "sid" => [
//                     "default" => SORT_DESC,
//                     "label" => "sid"
//                 ]
//             ]
//         ]);
        
//         $pagination = new Pagination([
//             "defaultPageSize" => 15,
//             "totalCount" => $query->count()
//         ]);
        
//         $result=$query->orderBy($sort->orders)->offset($pagination->offset)->limit($pagination->limit)->all();
        
//         return $this->render("index",[
//             "result"=>$result,
//             "pagination"=>$pagination
//         ]);
        $searchModel = new TaoZhuangSearch();
        $dataProvider = $searchModel->search();
//        print_r($dataProvider->getModels());
        return $this->render('index',[
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider
        ]);
//            $res=TaoZhuang::findBySql("select  taozhuang.`name` as  tz_name,  sys_image.url  as  img_url from  taozhuang,  sys_image  where  taozhuang.img_url_id = sys_image.id")->asArray()->all();
//            print_r($res);
    }
}